package Thread;

/**
 * 线程的常用属性
 */
public class propertyTherad {
    public static void main(String[] args) {
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i <10 ; i++) {
                    System.out.println(Thread.currentThread().getName()+"我还活着~~");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println(Thread.currentThread().getName()+"我即将嘎了~~");
            }
        },"测试线程");

        System.out.println(Thread.currentThread().getName()+"ID:"+thread.getId());
        System.out.println("状态:"+Thread.currentThread().getState());
        System.out.println("优先级:"+Thread.currentThread().getPriority());
        System.out.println("是否为后台线程:"+Thread.currentThread().isDaemon());
        System.out.println("是否存活:"+Thread.currentThread().isAlive());
        System.out.println("子线程是否存活:"+thread.isAlive());
        thread.start();
    }
}
